home *** CD-ROM | disk | FTP | other *** search
/ Joystick Magazine 1996 May / cd joy 71No13.iso / pc / demos / eurosoc / source / sosm.h < prev    next >
C/C++ Source or Header  |  1995-02-05  |  10KB  |  456 lines

  1. /****************************************************************************
  2.  
  3.    File              : sosm.h
  4.  
  5.    Programmer(s)     : Don Fowler, Nick Skrepetos
  6.    Date              :
  7.  
  8.    Purpose           : Include Files For Zortech C++ Compiler
  9.  
  10.    Last Updated      :
  11.  
  12. ****************************************************************************
  13.                Copyright(c) 1993,1994 Human Machine Interfaces 
  14.                             All Rights Reserved
  15. ****************************************************************************/
  16.  
  17. #ifndef  _SOS_MIDI_DEFINED   
  18. #define  _SOS_MIDI_DEFINED   
  19.  
  20. #include "sosdefs.h"
  21. #include "sos.h"
  22.  
  23. #pragma pack(4)
  24.  
  25. #define  _SOS_MIDI_ERR          -1
  26.  
  27. // number of drivers allowed to be open at one time
  28. #define  _SOS_MIDI_MAX_DRIVERS  5
  29.  
  30. // maximum number of allowed channels
  31. #define  _SOS_MIDI_MAX_CHANNELS    0x10
  32.  
  33. // structure definition for the capabilities
  34. typedef struct
  35. {
  36.    BYTE     szDeviceName[ 32 ];  // device name
  37.    WORD     wDeviceVersion;      // device version
  38.    WORD     wFlags;              // miscellaneous flags   
  39.    WORD     wProcessData;        // process data before sending to driver
  40.    short far *   lpPortList;          // list of usable ports
  41.    short far *   lpIRQList;           // list of usable irq channels
  42.    WORD     wDeviceID;           // ID for the device
  43.    
  44. } _SOS_MIDI_CAPABILITIES; 
  45.  
  46. #define  LPSOSMIDIDEVICECAPS  _SOS_MIDI_CAPABILITIES far *
  47.  
  48. // call indexes for the loadable drivers
  49. enum
  50.    _DRV_MIDI_GET_CAPS,
  51.    _DRV_MIDI_GET_CALL_TABLE,
  52.    _DRV_MIDI_SPECIAL1
  53. };
  54.  
  55. // file header for the driver
  56. typedef struct
  57. {
  58.    // name ID
  59.    BYTE  szName[ 32 ];
  60.  
  61.    // number of drivers in the file
  62.    WORD  wDrivers;
  63.  
  64.    // offset of first driver
  65.    WORD  lOffset;
  66.  
  67.    // size of the file
  68.    WORD  lFileSize;
  69.  
  70. } _MIDIFILEHEADER;
  71.  
  72. // driver header structure
  73. typedef struct
  74. {
  75.    // name ID
  76.    BYTE  szName[ 32 ];
  77.  
  78.    // offset of next driver
  79.    WORD  lNextDriver;
  80.  
  81.    // size of current driver
  82.    WORD  wSize;
  83.  
  84.    // id for the current device
  85.    WORD  wDeviceID;
  86.  
  87.    // id for the extender type
  88.    WORD  wExtenderType;
  89.  
  90. } _MIDIDRIVERHEADER;
  91.  
  92. // device hardware information
  93. typedef struct
  94. {
  95.    // port to be used
  96.    WORD  wPort;
  97.  
  98.    // IRQ for the board
  99.    WORD  wIRQ;
  100.  
  101.    // extra parameter
  102.    WORD  wParam;
  103.  
  104. } _SOS_MIDI_HARDWARE;
  105.  
  106. // structure for initializing a digital driver 
  107. typedef struct
  108. {
  109.    // ID for the digital driver
  110.    WORD  wDriverID;
  111.  
  112.    // timer rate to use
  113.    WORD  wTimerRate;
  114.  
  115.    // timer callback rate to use
  116.    WORD  wTimerCallbackRate;
  117.  
  118.    // max voices for the driver to use
  119.    WORD  wMaxVoices;
  120.  
  121.    // velocity sensing flag
  122.    WORD  wVelocitySensing;
  123.  
  124.    // init driver info
  125.    _SOS_INIT_DRIVER far * sDIGIDriverInfo;
  126.  
  127.    // hardware information
  128.    _SOS_HARDWARE far *  sDIGIHardwareInfo;    
  129.  
  130. } _SOS_MIDI_DIGI_INIT_DRIVER;
  131.  
  132. // structure for initializing a driver
  133. typedef struct
  134. {  
  135.    // type of driver to use if using a digital driver
  136.    WORD        wDIGIDriverID;
  137.  
  138.    // pointer to driver memory
  139.    VOID far * lpDriverMemory;
  140.    VOID far * lpDriverMemoryCS;
  141.  
  142.    // pointer to digital driver initialization information
  143.    _SOS_MIDI_DIGI_INIT_DRIVER far * sDIGIInitInfo;
  144.  
  145.    // miscellaneous WORD parameter for driver
  146.    WORD  wParam;
  147.  
  148.    // miscellaneous DWORD parameter for driver
  149.    DWORD dwParam;
  150.  
  151. } _SOS_MIDI_INIT_DRIVER;
  152.  
  153. // structure for starting a song
  154. typedef struct
  155. {  
  156.    // pointer to song memory 
  157.    BYTE _huge * lpSongData;
  158.  
  159.    // pointer to callback function for pertinent song information
  160.    VOID ( far * lpSongCallback )( WORD );
  161.  
  162. } _SOS_MIDI_INIT_SONG;
  163.  
  164. // define to indicate that track mapping can be used
  165. // from the midi file for the song
  166. #define  _MIDI_MAP_TRACK   0xff
  167.   
  168. // MIDI channel to device mapping structure
  169. typedef struct
  170. {
  171.    // track to device mapping information
  172.    WORD wTrackDevice[ 32 ];
  173.      
  174. } _SOS_MIDI_TRACK_DEVICE;
  175.  
  176. // MIDI channel to device mapping structure
  177. typedef struct
  178. {
  179.    // track to device mapping information
  180.    WORD wTrackDevice[ 32 ][ 5 ];
  181.      
  182. } _SOS_MIDI_TRACK_DEVICE1;
  183.  
  184. // NEW
  185. // header for the NDMF format MIDI file 
  186. typedef struct
  187. {
  188.    // ID for the file
  189.    BYTE  szFileID[ 32 ];
  190.  
  191.    WORD dwBranchOffset;
  192.    WORD temp1;
  193.    WORD temp2;
  194.    WORD temp3;
  195.  
  196. //   // name of the instrument file to use with the song   
  197. //   BYTE  szInstrumentFile[ 16 ];
  198.  
  199.    // number of tracks in the song
  200.    WORD  wNDMFTracks;
  201.  
  202.    // ticks/quarter note song is used at
  203.    WORD  wTicksQuarterNote;
  204.  
  205.    // tempo
  206.    WORD  wTempo;
  207.  
  208.    // time for song to play at current tempo
  209.    WORD  wTimeToPlay;
  210.  
  211.    // channel mapping priority information
  212.    WORD  wChannelPriority[ _SOS_MIDI_MAX_CHANNELS ];
  213.  
  214.    // channel mapping information
  215.    _SOS_MIDI_TRACK_DEVICE1 sTrackMap;
  216.  
  217.    // array of flags for which controllers to restore on a loop/branch
  218.    BYTE  bCtrlRestore[ 128 ];
  219.  
  220.    // pointer to callback function for song to call with 
  221.    // pertinent information
  222.    VOID ( far * lpSongCallback )( WORD ); 
  223.  
  224. } _NDMF_FILE_HEADER;
  225. // END
  226.  
  227. // header for the tracks in the NDMF format MIDI file
  228. typedef struct
  229. {
  230.    // track number
  231.    WORD  wTrackNumber;
  232.  
  233.    // length of the track
  234.    WORD  wTrackLength;
  235.  
  236.    // channel used on the track
  237.    WORD  wChannel;
  238.  
  239. } _NDMF_TRACK_HEADER;
  240.  
  241. // MIDI event structure
  242. typedef struct
  243. {
  244.    // dummy name to access midi data from
  245.    BYTE  bMidiData[ 256 ];
  246.  
  247. } _NDMF_MIDI_EVENT;
  248.  
  249. // maximum number of songs that can be played at any time
  250. #define  _SOS_MIDI_MAX_SONGS     8
  251.  
  252. // maximum number of tracks that can be used
  253. #define  _SOS_MIDI_MAX_TRACKS    32
  254.  
  255. // number of driver functions
  256. #define  _SOS_MIDI_DRV_FUNCTIONS 12
  257.  
  258. // enumeration for all of the drv functions
  259. enum
  260. {
  261.    _MIDI_DRV_SEND_DATA,
  262.    _MIDI_DRV_INIT,
  263.    _MIDI_DRV_UNINIT,
  264.    _MIDI_DRV_RESET,
  265.    _MIDI_DRV_SET_INST_DATA
  266. };
  267.  
  268. // defines for the loadable driver ids
  269. #define  _MIDI_SOUND_MASTER_II      0xa000
  270. #define  _MIDI_MPU_401              0xa001
  271. #define  _MIDI_FM                   0xa002
  272. #define  _MIDI_OPL2                 0xa002
  273. #define  _MIDI_CALLBACK             0xa003
  274. #define  _MIDI_MT_32                0xa004
  275. #define  _MIDI_DIGI                 0xa005  
  276. #define  _MIDI_INTERNAL_SPEAKER     0xa006
  277. #define  _MIDI_WAVE_TABLE_SYNTH     0xa007  
  278. #define  _MIDI_AWE32                0xa008  
  279. #define  _MIDI_OPL3                 0xa009  
  280. #define  _MIDI_GUS                  0xa00a  
  281.  
  282. // structure for the hmi instrument file header
  283. typedef struct
  284. {
  285.    // file id type
  286.    BYTE  szFileID[ 32 ];
  287.  
  288.    // file version
  289.    WORD  wFileVersion;
  290.  
  291.    // size of the file
  292.    WORD dwFileSize;
  293.  
  294. } _HMI_INS_FILE_HEADER;
  295.  
  296.  
  297. // define for identifying a drum instrument  
  298. #define  _SOS_MIDI_DRUM_INS   ( short )0x8000
  299.  
  300. // maximum number of timer events that can be registered 
  301. #define  _TIMER_MAX_EVENTS    0x10  
  302.  
  303. // structure for digital driver queue element
  304. typedef struct _tagQueueElement
  305. {
  306.    // handle for the sample
  307.    WORD  wSampleHandle;
  308.  
  309.    // id for the sample
  310.    WORD  wSampleID;
  311.  
  312.    // velocity for the sample
  313.    WORD  wVelocity;
  314.  
  315.    // channel for the sample
  316.    WORD  wChannel;
  317.  
  318. } _DIGI_QUEUE_ELEMENT;
  319.  
  320. // maximum number of instruments that can be set in the 
  321. // digital driver
  322. #define  _MAX_INS    128
  323.  
  324. // define for the maximum number of times a channel can be stolen
  325. #define  _SOS_MIDI_MAX_LEVELS    0x04
  326.  
  327. // structure for MIDI information to be stored on the local stack
  328. // when a channel is stolen
  329. typedef struct
  330. {
  331.    // used element
  332.    BYTE  bUsed;
  333.  
  334.    // last pitch bend information sent
  335.    BYTE  bPitchBend;
  336.  
  337.    // channel volume
  338.    BYTE  bChannelVolume;
  339.  
  340.    // instrument information
  341.    BYTE  bInstrument;
  342.  
  343.    // sustain pedal
  344.    BYTE  bSustain;
  345.  
  346. } _SOS_MIDI_CHANNEL_DATA;
  347.  
  348. // flags for the debugging system
  349. #define  _SOS_DEBUG_NORMAL       0x0000
  350. #define  _SOS_DEBUG_NO_TIMER     0x0001
  351.  
  352. // ID for 32 bit MIDI file
  353. #define  _SOS_MIDI_FILE_ID       "HMIMIDIP"  
  354.  
  355. // structure for branch location controller
  356. typedef struct
  357. {
  358.    // offset from start of track data
  359.    WORD     dwOffset;
  360.  
  361.    // branch ID number
  362.    BYTE     bBranchID;
  363.  
  364.    // current instrument
  365.    BYTE     bInstrument;
  366.  
  367.    // current loop count for temporary storage
  368.    // so that a track can be looped without 
  369.    // needing any data from the program
  370.    BYTE     bLoopCount;
  371.  
  372.    // number of controller messages stored
  373.    BYTE     bCtrlChangeCount;
  374.  
  375.    // offset of control change information from start of file
  376.    WORD     lpCtrlChangeData;   
  377.    WORD     lpCtrlChangeDataTemp;
  378.    
  379.    // reserved fields
  380.    WORD     wReserved1;
  381.    WORD     wReserved2;
  382.  
  383. } _SOS_BRANCH_POINT;
  384.  
  385. #define  _SOS_MIDI_FADE_IN          0x01  
  386. #define  _SOS_MIDI_FADE_OUT         0x02  
  387. #define  _SOS_MIDI_FADE_OUT_STOP    0x04  
  388.  
  389. // structure for digital drums to use to store midi information
  390. typedef struct
  391. {
  392.    // current volume
  393.    WORD  wVolume;
  394.  
  395.    // current pan position
  396.    WORD  wPanPosition;
  397.  
  398.    // reserved
  399.    DWORD dwReserved;
  400.    
  401. } _SOS_MIDI_DIGI_CHANNEL;
  402.  
  403. // instrument file header structure
  404. typedef struct
  405. {
  406.    // file ID
  407.    BYTE  szID[ 32 ];
  408.  
  409.    // file version
  410.    WORD  wVersion;
  411.  
  412.    // instruments in file
  413.    WORD  wInstruments;
  414.  
  415.    // list of pointers to start sample structures
  416.    _SOS_START_SAMPLE far * lpStartSample[ _MAX_INS ];
  417.  
  418.    DWORD temp1;
  419.    DWORD temp2;
  420.  
  421. } _WAVE_FILE_HEADER;
  422.  
  423. #pragma pack()
  424.  
  425. // define for the busy error returned from send data
  426. #define  _ERR_DRIVER_BUSY  0xf000
  427.  
  428. // NEW
  429. // defines for the looping branch controllers
  430. #define  _SOS_SET_FLAG   103
  431. #define  _SOS_RESET_FLAG 104
  432. #define  _SOS_BRANCH1   108
  433. #define  _SOS_BRANCH2   109
  434. #define  _SOS_BRANCH3   110
  435. #define  _SOS_BRANCH4   111
  436. #define  _SOS_BRANCH5   112
  437. #define  _SOS_BRANCH6   113
  438. #define  _SOS_BRANCH7   114
  439. #define  _SOS_BRANCH8   115
  440. #define  _SOS_BRANCH9   116
  441. #define  _SOS_BRANCH10  117
  442. #define  _SOS_BRANCH11  118
  443. #define  _SOS_BRANCH12  119
  444. #define  _SOS_BRANCH13  120
  445. #define  _SOS_BRANCH14  121
  446.  
  447. // define for the program change controller flag
  448. #define  _SOS_PROGRAM_CHANGE_FLAG   108
  449.  
  450. // END
  451. #include "sosmdata.h"
  452. #include "sosmfnct.h"
  453.  
  454. #endif
  455.